drawcontext: Add a surface_resized() vfunc
authorBenjamin Otte <otte@redhat.com>
Sun, 8 Apr 2018 22:35:32 +0000 (00:35 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 8 Apr 2018 23:00:31 +0000 (01:00 +0200)
Call this vfunc whenever the surface's size has changed.

gdk/gdkdrawcontext.c
gdk/gdkdrawcontextprivate.h
gdk/gdksurface.c

index 0f020f93e33c63edb0c8c1408b1571d6923fa090..33324f44e35762aef4f7fd3c2daf23f73318efc8 100644 (file)
@@ -67,6 +67,11 @@ static GParamSpec *pspecs[LAST_PROP] = { NULL, };
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GdkDrawContext, gdk_draw_context, G_TYPE_OBJECT)
 
+static void
+gdk_draw_context_default_surface_resized (GdkDrawContext *context)
+{
+}
+
 static void
 gdk_draw_context_dispose (GObject *gobject)
 {
@@ -137,6 +142,8 @@ gdk_draw_context_class_init (GdkDrawContextClass *klass)
   gobject_class->get_property = gdk_draw_context_get_property;
   gobject_class->dispose = gdk_draw_context_dispose;
 
+  klass->surface_resized = gdk_draw_context_default_surface_resized;
+
   /**
    * GdkDrawContext:display:
    *
@@ -247,6 +254,19 @@ gdk_draw_context_end_frame (GdkDrawContext *context,
   priv->is_drawing = FALSE;
 }
 
+/*< private >
+ * gdk_draw_context_surface_resized:
+ * @context: a #GdkDrawContext
+ *
+ * Called by the #GdkSurface the @context belongs to when the size of the surface
+ * changes.
+ */
+void
+gdk_draw_context_surface_resized (GdkDrawContext *context)
+{
+  GDK_DRAW_CONTEXT_GET_CLASS (context)->surface_resized (context);
+}
+
 /**
  * gdk_draw_context_get_display:
  * @context: a #GdkDrawContext
index 0223787a1dec2267261474ff0faf08d231b54d68..33c4b725460a82108decb0f741ca1578c208f98d 100644 (file)
@@ -45,6 +45,7 @@ struct _GdkDrawContextClass
   void                  (* end_frame)                           (GdkDrawContext         *context,
                                                                  cairo_region_t         *painted,
                                                                  cairo_region_t         *damage);
+  void                  (* surface_resized)                     (GdkDrawContext         *context);
 };
 
 gboolean                gdk_draw_context_is_drawing             (GdkDrawContext         *context);
@@ -54,6 +55,8 @@ void                    gdk_draw_context_end_frame              (GdkDrawContext
                                                                  cairo_region_t         *painted,
                                                                  cairo_region_t         *damage);
 
+void                    gdk_draw_context_surface_resized        (GdkDrawContext         *context);
+
 G_END_DECLS
 
 #endif /* __GDK__DRAW_CONTEXT_PRIVATE__ */
index bc12fd589dba8230e972700f7dfec79f99bca458..d9bbcb753424b915fe1a25586cd80d7dc8ab390c 100644 (file)
@@ -622,6 +622,11 @@ gdk_surface_append_old_updated_area (GdkSurface *surface,
 void
 _gdk_surface_update_size (GdkSurface *surface)
 {
+  GSList *l;
+
+  for (l = surface->draw_contexts; l; l = l->next)
+    gdk_draw_context_surface_resized (l->data);
+
   gdk_surface_clear_old_updated_area (surface);
   recompute_visible_regions (surface, FALSE);
 }